import { _decorator, Component, Node, UITransform, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('bgContral')
export class bgContral extends Component {
    start() {

    }

    update(deltaTime: number) {
        const speed =50; // 可以调整速度 
        // 遍历子物体
       for (const element of this.node.children) {
        element.position = new Vec3(element.position.x,element.position.y-(speed*deltaTime),element.position.z)
        // 获取节点高度
        let nodeHeight = element.getComponent(UITransform)
        if(element.position.y<(-nodeHeight.height)){
            element.position = new Vec3(element.position.x
                ,element.position.y+(nodeHeight.height*2),element.position.z)
        }
        
       }
    }
}


